<?php
error_reporting("E_ALL");ini_set("display_errors", 1);
$getdata=$_REQUEST;
if(empty($getdata))$getdata=$_POST?$_POST:$_GET;
$type=empty($getdata['type'])?'':$getdata['type'];
include("include/function.php");
//header("content-Type: application/json; charset=utf-8");
$config = include("config.php");
include("include/".$config['DB_TYPE'].".class.php");
$db = new db;
$db->connect($config['DB_HOST'],$config['DB_USER'],$config['DB_PWD'],$config['DB_NAME'], $config['DB_PCONNECT']);
      
$page = empty($getdata['page'])?1:$getdata['page'];
$id = empty($getdata['id'])?0:$getdata['id'];
$length=100;
$where='status=1 and is_delete=1';
if($id){
    $where.=" and student_id>".$id;
}
$orderids=[];
$insert=0;
$sql="select * from hema_student where ".$where.' order by student_id limit '.$length;
$list = $db->get_all($sql);if(empty($list))exit('over');
foreach($list as $v){$id=$v['student_id'];
    if(in_array($id,$orderids))continue;
        $mobile = !empty($v['mobile'])?$v['mobile']:$v['parentPhone'];
        if(empty($mobile))continue;
        $ssql = "update order_info_hs set buyerMobile='".$mobile."' where buyerMobile='' and studentUuid='".$v['uuid']."';";
        $res = $db->query($ssql);
        
        if($res)$insert++;
}
$log = $id.'导入成功,：'.$insert.'条';
echo $log.'<script>location.href="?page='.$page.'&id='.$id.'";</script>';

//echo count($sqlarr)."\n";
//echo implode(";\n",$sqlarr);
?>